package com.cetc.sdp.kmga.cs.audit;

import java.io.Serializable;

/**
 * @description:
 * @author： DengQiang
 * @date: 2017/9/5 13:09
 */
public final class ResourceKey implements Serializable {

    private String ip;

    private int port;

    private int src;

    public ResourceKey(String ip, int port, int src) {
        if (ip == null) {
            throw new IllegalArgumentException("IP cannot be null for ResourceKey");
        }
        this.ip = ip;
        this.port = port;
        this.src = src;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getSrc() {
        return src;
    }

    public void setSrc(int src) {
        this.src = src;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ResourceKey that = (ResourceKey) o;

        if (port != that.port) return false;
        if (src != that.src) return false;

        return ip != null ? ip.equals(that.ip) : that.ip == null;
    }

    @Override
    public int hashCode() {
        int result = ip != null ? ip.hashCode() : 0;
        result = 31 * result + port;
        return result;
    }
}
